#include <vector>
#include <fstream>
#include <iostream>

using namespace std;

vector<int> capacities;
vector<int> milks;

void pour(int from, int to) {
  // 1. 编号为 from 的桶里，当前有多少牛奶
  int m = milks.at(from);

  // 2. 编号为 to 的桶里，还能装多少牛奶
  int n = capacities.at(to) - milks.at(to);

  // 倒出去的量
  int amount = min(m, n);

  milks.at(from) -= amount;
  milks.at(to) += amount;
}

int main(int argc, char const *argv[])
{
  // 处理输入
  ifstream ifs("MixMilk.in");

  for (int i = 0; i < 2; ++i) {
    int c = 0, m = 0;
    ifs >> c >> m;

    capacities.push_back(c);
    milks.push_back(m);
  }

  for (int i = 0; i < 100; ++i) {
    // John 的三个桶编号为 0 1 2
    // i = 0 pour(0, 1) -> pour(0, 1)
    // i = 1 pour(1, 2) -> pour(1, 2)
    // i = 2 pour(2, 3) -> pour(2, 0)

    // i = 3 pour(3, 4) -> pour(0, 1)
    // i = 4 pour(4, 5) -> pour(1, 2)
    // i = 5 pour(5, 6) -> pour(2, 0)

    // 假设有一个负责倒牛奶的函数 pour
    pour(i % 3, (i + 1) % 3);
  }

  // milks 里就是答案
  ofstream ofs("MixMilk.out");
  ofs << milks.at(0) << endl << milks.at(1) << endl << milks.at(2);

  return 0;
}
